package com.atguigu.flink.charkoer04;

import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;


public class TransFrom_Map {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 2000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);

        env
                .fromElements(1, 2, 3, 4, 5).map(new RichMapFunction<Integer, Integer>() {

            @Override
            public void open(Configuration parameters) throws Exception {
                System.out.println("TransFrom_Map.open");
            }

            @Override
            public void close() throws Exception {
                System.out.println("TransFrom_Map.close");
            }

            @Override
            public Integer map(Integer value) throws Exception {
                System.out.println("TransFrom_Map.map");
                return value * value;
            }
        }).print();


        env.execute();
    }

}
